class Solution(object):
    def circularPermutation(self, n, start):
        def search(k):
            if k == 1:
                return [0, 1]
            else:
                out = search(k - 1)
                out1 = [(num << 1) for num in out]
                out2 = [(num << 1) + 1 for num in out]
                out2.reverse()
                return out1 + out2

        out = search(n)
        index = out.index(start)
        return out[index:] + out[:index]

